import java.time.format.DateTimeFormatter;

public class YearMonth {
    private  int Year;
    private  int Month;
    public YearMonth(int year, int month) {
        Year=year;
        Month=month;
    }
    public  YearMonth(String yearMonth){
        this(Integer.parseInt(yearMonth.substring(0,4)),
                Integer.parseInt(yearMonth.substring(4,6)));

    }
    // 静态方法，用于根据字符串和日期格式化器解析并创建 YearMonth 对象
    public static YearMonth parse(String yearMonthString, DateTimeFormatter formatter) {
        java.time.YearMonth parsed = java.time.YearMonth.parse(yearMonthString, formatter);
        return new YearMonth(parsed.getYear(), parsed.getMonthValue());
    }
    // 获取月份值的方法，与 getMonth 功能相同
    public int getMonthValue() {
        return Month;
    }

    public int getYear() {
        return Year;
    }

    public int getMonth() {
        return Month; }
}
